package cn.kmbeast.controller;

import cn.kmbeast.aop.Pager;
import cn.kmbeast.pojo.api.Result;
import cn.kmbeast.pojo.dto.query.extend.HealthModelConfigQueryDto;
import cn.kmbeast.pojo.dto.update.HealthModelConfigDto;
import cn.kmbeast.pojo.entity.HealthModelConfig;
import cn.kmbeast.service.HealthModelConfigService;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/health-model-config")
public class HealthModelConfigController {
    
    /**
     * healthModelConfigService 是健康模型业务的接口  实现自动装配
     */
    @Resource
    private HealthModelConfigService healthModelConfigService;


    /**
     * 健康模型新增的方法
     * @param HealthModelConfig  健康模型新增数据
     * @return Result 通用响应数据
     */
    @PostMapping("/save")
    public Result<Void> save(@RequestBody HealthModelConfig HealthModelConfig) {
        return healthModelConfigService.save(HealthModelConfig);
    }

    /**
     * 健康模型的批量删除
     * @param ids  接受健康模型id的List集合
     * @return Result<Void>
     */
    @PostMapping("/batchDelete")
    public Result<Void> batchDelete(@RequestBody List<Long> ids) {
        return healthModelConfigService.batchDelete(ids);
    }

    /**
     * 健康模型的修改
     * @param HealthModelConfig 接受健康模型
     * @return Result<Void>
     */
    @PutMapping("/update")
    public Result<Void> update(@RequestBody HealthModelConfig HealthModelConfig) {
        return healthModelConfigService.update(HealthModelConfig);
    }

    /**
     * 健康模型的查询 对名称进行一个模糊查询
     *
     * @param healthModelConfigQueryDto 接受健康模型对应的查询类
     * @return Result<List < HealthModelConfigDto>> 返回健康模型列表
     */
    @Pager
    @PostMapping("/query")
    public Result<List<HealthModelConfig>> query(@RequestBody HealthModelConfigQueryDto healthModelConfigQueryDto) {
        System.out.println("查询"+healthModelConfigQueryDto.toString());
        return healthModelConfigService.query(healthModelConfigQueryDto);
    }

}

    

